#include "hash.h"
#include <stdio.h>
#include <stdlib.h>

void HashMapShowAll(HashMap *map)
{
    if (map == NULL)
    {
        return;
    }

    Node *pNode    = NULL;
    Node *pPreNode = NULL;  

    for (int i = 0; i < MAX_SIZE; i++)
    {
        pNode = map->list[i];
        while (pNode != NULL)
        {
            printf("Node:%p Key:%12d Value: %12d\n", pNode, pNode->key, pNode->value);
            pNode = pNode->next;
        }
    }
}

int main()
{
    HashMap *map = HashMapEMPTY();
    Node node    = {0};
    Node *pNode  = NULL;
    int sum      = 1200;

    /* 添加 */
    for (int i = 0; i < sum; i++)
    {
        node.key   = rand() % 2000;
        node.value = rand();
        map->put(map, node);
    }

    printf("map count:%d\n", map->count);

    /* 删除 */
    for (int i = 0; i < 700; i++)
    {
        node.key = rand() % 100;
        map->del(map, node);
        // del(map, node);
    }

    printf("map count:%d\n", map->count);


    /* 销毁 */
    HashMapDestroy(map);
    map = NULL;

    return 0;
}